import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'logic.dart';

class IndexPage extends StatelessWidget {
  IndexLogic logic = Get.put(IndexLogic());
  final state = Get.find<IndexLogic>().state;

  IndexPage({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<IndexLogic>(builder: (builder) {
      return Scaffold(
          body: PageView(
            controller: state.pageController,
            children: state.listPages,
            onPageChanged: (position) => {logic.selectedPosition(position)},
          ),
          bottomNavigationBar: BrnBottomTabBar(
              fixedColor: Colors.green,
              currentIndex: state.selectedIndex,
              onTap: (position) => {
                    //tab切换你点击事件
                    logic.selectedPosition(position),
                    state.pageController.jumpToPage(position)
                  },
              items: state.list));
    });
  }
}
